HAL IRDA types migration

This section provides information about the HAL IRDA types migration.

Important

In HAL2, the IRDA driver is removed, and IRDA functionalities are integrated within the HAL UART driver.

HAL IRDA callback ID type definition

HAL1

HAL2

typedef enum
{
    HAL_IRDA_TX_HALFCOMPLETE_CB_ID,
    HAL_IRDA_TX_COMPLETE_CB_ID,
    HAL_IRDA_RX_HALFCOMPLETE_CB_ID,
    HAL_IRDA_RX_COMPLETE_CB_ID,
    HAL_IRDA_ERROR_CB_ID,
    HAL_IRDA_ABORT_COMPLETE_CB_ID,
    HAL_IRDA_ABORT_TRANSMIT_COMPLETE_CB_ID,
    HAL_IRDA_ABORT_RECEIVE_COMPLETE_CB_ID,
    HAL_IRDA_MSPINIT_CB_ID,
    HAL_IRDA_MSPDEINIT_CB_ID
} HAL_IRDA_CallbackIDTypeDef;

Removed.

Note

The callback registration in HAL2 is handled by specific functions for each UART event. See Register callbacks for more details.

HAL_IRDA_MSPINIT_CB_ID and HAL_IRDA_MSPDEINIT_CB_ID are removed because the functions HAL_IRDA_MspInit() and HAL_IRDA_MspDeInit() are removed.

Related concepts:


HAL IRDA state type definition

In HAL2, The IRDA protocol shares the same state machine as the UART, which is managed through three distinct state machines:
  • Global state machine: hal_uart_state_t

  • Reception state machine: hal_uart_rx_state_t

  • Transmission state machine: hal_uart_tx_state_t

HAL1

HAL2

typedef enum
{
  HAL_IRDA_STATE_RESET,
  HAL_IRDA_STATE_READY,
  HAL_IRDA_STATE_BUSY,
  HAL_IRDA_STATE_BUSY_TX,
  HAL_IRDA_STATE_BUSY_RX,
  HAL_IRDA_STATE_BUSY_TX_RX
  HAL_IRDA_STATE_TIMEOUT,
  HAL_IRDA_STATE_ERROR
} HAL_IRDA_StateTypeDef;
typedef enum
{
  HAL_UART_STATE_RESET,
  HAL_UART_STATE_INIT,
  HAL_UART_STATE_CONFIGURED
} hal_uart_state_t;

typedef enum
{
  HAL_UART_RX_STATE_RESET,
  HAL_UART_RX_STATE_IDLE,
  HAL_UART_RX_STATE_ACTIVE,
  HAL_UART_RX_STATE_ABORT
} hal_uart_rx_state_t;

typedef enum
{
  HAL_UART_TX_STATE_RESET,
  HAL_UART_TX_STATE_IDLE,
  HAL_UART_TX_STATE_ACTIVE,
  HAL_UART_TX_STATE_ABORT
} hal_uart_tx_state_t;

HAL IRDA clock source type definition

HAL1

HAL2

typedef enum
{
  IRDA_CLOCKSOURCE_CSI,
  IRDA_CLOCKSOURCE_HSI,
  IRDA_CLOCKSOURCE_LSE,
  IRDA_CLOCKSOURCE_PCLK1,
  IRDA_CLOCKSOURCE_PCLK2
  IRDA_CLOCKSOURCE_UNDEFINED
               .
               .
               .
} IRDA_ClockSourceTypeDef;

Removed: In HAL1, this structure was used internally for baudrate calculations and was not exposed to the user.


HAL IRDA initialization type Definition

HAL1

HAL2

typedef struct
{
    uint32_t BaudRate;
    uint32_t WordLength;
    uint32_t Parity;
    uint32_t Mode;
    uint8_t  Prescaler;
    uint16_t PowerMode;
    uint32_t ClockPrescaler;
} IRDA_InitTypeDef;
typedef struct
{
    uint32_t baud_rate;
    hal_uart_word_length_t word_length;
    hal_uart_parity_t parity;
    hal_uart_direction_t direction;
    uint32_t irda_prescaler;
    hal_uart_irda_power_mode_t irda_power_mode;
    hal_uart_prescaler_t clock_prescaler;
} hal_uart_irda_config_t;

Related concept: Replaced TypeDef suffix with _t in type names


HAL IRDA handle type Definition

HAL1

HAL2

IRDA_HandleTypeDef
hal_uart_handle_t

Related concepts:

HAL IRDA callback type Definition

HAL1

HAL2

pIRDA_CallbackTypeDef

hal_uart_cb_t